package com.ly.web.controller.erp;

import java.util.List;

import com.ly.heart.service.IAssetsChangeMethodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.AssetsChangeMethodEntity;
import com.ly.common.utils.poi.ExcelUtil;

import javax.annotation.Resource;

/**
 * 资产变动方式Controller
 *
 * @author cxl
 * @date 2024-09-03
 */
@Api(value = "资产变动方式", tags = "资产变动方式")
@RestController
@RequestMapping("/heart/AssetsChangeMethod")
public class AssetsChangeMethodController extends BaseController {

    @Resource
    private IAssetsChangeMethodService assetsChangeMethodService;

    /**
     * 查询资产变动方式列表
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsChangeMethod:list')")
    @PostMapping("/list")
    @ApiOperation("查询资产变动方式列表")
    public  AjaxResult getAssetsChangeMethodList(AssetsChangeMethodEntity assetsChangeMethod){
        return assetsChangeMethodService.getAssetsChangeMethodList(assetsChangeMethod);
    }

    /**
     * 获取资产变动方式详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsChangeMethod:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取资产变动方式详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(assetsChangeMethodService.selectAssetsChangeMethodEntityById(id));
    }

    /**
     * 新增资产变动方式
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsChangeMethod:add')")
    @Log(title = "资产变动方式", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增资产变动方式")
    public AjaxResult add(@RequestBody AssetsChangeMethodEntity assetsChangeMethodEntity)
    {
        return toAjax(assetsChangeMethodService.insertAssetsChangeMethodEntity(assetsChangeMethodEntity));
    }

    /**
     * 修改资产变动方式
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsChangeMethod:edit')")
    @Log(title = "资产变动方式", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改资产变动方式")
    public AjaxResult edit(@RequestBody AssetsChangeMethodEntity assetsChangeMethodEntity)
    {
        return toAjax(assetsChangeMethodService.updateAssetsChangeMethodEntity(assetsChangeMethodEntity));
    }

    /**
     * 删除资产变动方式
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsChangeMethod:remove')")
    @Log(title = "资产变动方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除资产变动方式")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(assetsChangeMethodService.deleteAssetsChangeMethodEntityByIds(ids));
    }

    /**
     * 导出资产变动方式列表
     */
    @PreAuthorize("@ss.hasPermi('heart:AssetsChangeMethod:export')")
    @Log(title = "资产变动方式", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出资产变动方式列表")
    public AjaxResult export(AssetsChangeMethodEntity assetsChangeMethodEntity)
    {
        List<AssetsChangeMethodEntity> list = assetsChangeMethodService.selectAssetsChangeMethodEntityList(assetsChangeMethodEntity);
        ExcelUtil<AssetsChangeMethodEntity> util = new ExcelUtil<AssetsChangeMethodEntity>(AssetsChangeMethodEntity.class);
        return util.exportExcel(list, "AssetsChangeMethod");
    }

    @Log (title = "禁用/反禁用资产变动方式", businessType = BusinessType.OTHER)
    @PostMapping ("/disabled")
    @ApiOperation ("禁用/反禁用资产变动方式")
    public AjaxResult disabled (@RequestParam("id") String id) {
        return assetsChangeMethodService.disable ( id );
    }



}
